<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!-- 修改密码页面  -->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
<title>彩妆  商城</title>
  <!-- Bootstrap Core CSS -->
    <link rel="stylesheet" href="/Shopping/static/css/bootstrap.min.css"  type="text/css">
	<link rel="stylesheet" href="/Shopping/static/css/font-slider.css"  type="text/css">
	<!-- Custom CSS -->
    <link rel="stylesheet" href="/Shopping/static/css/style.css">
	
	<!-- jQuery and Modernizr-->
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
	<script src="/Shopping/static/lib/layer/2.4/layer.js"></script>
			<!-- Core JavaScript Files -->  	 
    <script src="/Shopping/static/js/bootstrap.min.js"></script>
	
	
</head>
<body>
<nav id="top">
		<div class="container">
			<div class="row">
				<div class="col-xs-6">
	
				</div>
				<div class="col-xs-6">
					<ul class="top-link">
						<li><a ><span class="glyphicon glyphicon-user"></span> </a></li>
						<li><a href="${prePage}"><span></span>返回</a></li>
					</ul>
				</div>
			</div>
		</div>
	</nav>
<!--Header-->
	<header class="container">
		<div class="row">
			<div class="col-md-4">
				<div id="logo">
					<font size="10" color="#cc3300" face="宋体"><i><strong>Shoopping</strong></i>
				</font></div>
			</div>
			<div class="col-md-4">
				<form class="form-search">  
					<input type="text" class="input-medium search-query">  
					<button type="button" class="btn"><span class="glyphicon glyphicon-search"></span></button>  
				</form>
			</div>
			<div class="col-md-4">
				<div id="cart"><a  id="shopcart" class="btn btn-1" href="cart.html"><span class="glyphicon glyphicon-shopping-cart"></span>购物车</a></div>
			</div>
		</div>
	</header>
	<!--Navigation-->
    <nav id="menu" class="navbar">
		<div class="container">
			<div class="navbar-header"><span id="heading" class="visible-xs">目录</span>
			  <button type="button" class="btn btn-navbar navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"><i class="fa fa-bars"></i></button>
			</div>
			<div class="collapse navbar-collapse navbar-ex1-collapse">
				<ul class="nav navbar-nav">
						<li><a href="/Shopping/PersonInfo/personInfo">个人信息中心</a></li>
					<li><a href="/Shopping/RePassword/rePassword">修改密码</a></li>
				</ul>
			</div>
		</div>
	</nav>
	<!--//////////////////////////////////////////////////-->
	<!--///////////////////Account Page///////////////////-->
	<!--//////////////////////////////////////////////////-->
	<div id="page-content" class="single-page">
		<div class="container">
			<div class="row">
				<div class="col-lg-12">
					<ul class="breadcrumb">
						<li><a >首页</a></li>
						<li><a >修改密码</a></li>												
					</ul>
				</div>
			</div>
			<div class="col-md-6"  align="center">
					<div class="heading"><h2>修改密码</h2></div>
					<form name="form2" id="ff2" >
					<div class="form-group">
							<input type="password" class="form-control" placeholder="请输入你当前的密码:" name="oldpassword" id="oldpassword" required>
						</div>
						<div class="form-group">
							<input type="password" class="form-control" placeholder="新密码 :" name="password" id="password" required>
						</div>
						<div class="form-group">
							<input type="password" class="form-control" placeholder="再次确认新密码 :" name="repassword" id="repassword" required>
						</div>
						
							<button type="button" class="btn btn-1" name="change" id="change">修改</button>
					</form>
				</div>
</body>
<script>
	$(document).ready(function(){
		 updatePassword();
	});
	
	function validate(){ //验证输入的正确性
		var res = true;
		if($("#password").val()==''){
			layer.msg('密码不为空',{icon:0,time:2000});
			res = false;
		}
		if($("#repassword").val()==''){
			layer.msg('确认密码不为空',{icon:0,time:2000});
			res = false;
		}
		if($("#password").val()==$("#repasswod").val()){
			layer.msg('两次密码不一致',{icon:0,time:2000});
			res = false;
		}
		if($("#oldpassword").val()==''){
			layer.msg('原始密码不能为空',{icon:0,time:2000});
			res = false;
		}
	

		return res;
	}
	function updatePassword(){ //注册
		
			$("#change").click(function(){
				if(validate()){
					$.ajax({
					url:"/Shopping/RePassword/change",
					type:"get",
					dataType:"json",
					data:{"oldpassword":$("#oldpassword").val(),"password":$("#password").val()},
					async:false,
					success:function(data){
						if(data.res==1){
							//alert('success');
							layer.msg('修改密码成功',{icon:0,time:20000});
							window.location.href="${prePage}";
						}
						if(data.res==2){
						
							layer.msg('修改密码失败！',{icon:0,time:20000});
						}
						
					},
					error:function(){
						alert('error');
					}
				}); 
				} else {
					
				}
			});
		
		
			
	}
</script>
</html>